package com.srp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.srp.pojo.DataFile;
import com.srp.pojo.GetUserInfoReturn;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TreeMapper extends BaseMapper<DataFile> {
    @Select("select url from file where  name=#{name}" )
    String getUrlWithName(String name);
    @Insert("insert into decision_tree(id,decision_tree_structure,file_name)" +
            " value (#{id},#{decision_tree_structure},#{file_name})")
    int insertIdAndDecisionTreeStructure(String id,String decision_tree_structure,String file_name);
    @Delete("delete from decision_tree where id = #{id}")
    void delById(String id) ;
    @Select("select  decision_tree_structure from  decision_tree where id = #{id}")
    String getDecisionTreeById(String id);


    @Insert("insert into user_file(user_id,file_id) values (#{user_id},#{file_id})")
    void giveUserFileRight(String user_id, int file_id);

    @Select("select file_id from user_file where user_id=#{id}")
    List<String> getDeleteRight(String id);

    @Select("select file_name from decision_tree where id=#{id}")
    String getFileName(String id);

    @Delete("DELETE FROM user_file WHERE file_id = #{id}")
    void deleteRowsByFileId(String id);

    @Select("select name from testdata")
    List<String> getTestDataName();

    @Insert("insert into testdata(name,url) values (#{name},#{url})")
    void insertTestData(String name,String url);

    @Select("select url from testdata where id=#{id}")
    String findTestDataUrl(int id);

    @Delete("delete from testdata where id=#{id}")
    void deleteTestDataById(String id);

}
